set=ISO-8859-1">etitle>Chapx r 12. VFS Moduleses itle>elinkcrelsshome" href="index.html" itle="SAMBA Deselop&vs Guide">elinkcrelssup" href="pt03.html" itle="Pdr  III. Samba Subsystems>nelinkcrelssprevious" href="rpc-plugin.html" itle="Chapx r 11. RPC Pluggnble Modules">elinkcrelssnixt" href="registry.html" itle="Chapx r 13. Th0tregistry subsystem">e/heap> slink="#840084" allnk="#0000FF>msuch4n classnavheaper"ms nble width="100%" stmmury="Navigaary.theaper"ms rr< h ctlspan="3" allgn="cdex r>nChapx r 12. VFS Moduleses hrn>csaccesskey="p" href="rpc-plugin.html">Prevesa> Nextesa> lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle>n>csen m="vfs>nesa>Chapx r 12. VFS Modulesesh2msptlemsuchmsuch4n classauthorannh34n classauthorannspan4n classf rsten m>nAlexan r nspan4n classsuren m>nBokovoyamh3msuch4n classaffiliatLDI">euch4n classaddress"msp><ncshref="mailto:ab@samba.org">ab@samba.orgesa>>tn t>nStefan nspan4n classsuren m>nMetzmach ramh3msuch4n classaffiliatLDI">euch4n classaddress"msp><ncshref="mailto:metze@samba.org">metze@samba.orgesa>>tn t> 27 May 2003 Tnble of Ct "dexstnb>>ncshref="vfs.html#ass517991>>Trg Samba (Posix) VFS lay&vtnspan>amemeltdmsuSuccesnspan4n classsect2>>ncshref="vfs.html#ass517997>>Trg generul iut& facetnspan>amemeltesnspan4n classsect2>>ncshref="vfs.html#ass518094>nPos Lble VFS up&vatry. lay&vstnspan>amemelill Opuduccesnspan4n classsect1>>ncshref="vfs.html#ass518168">Trg Int& acery. betwee ctrg Samba VFS subsystemFad"ath0tmodulesesa>tnspan>amemeltdmsuSuccesnspan4n classsect2>>ncshref="vfs.html#ass518174">I ieralizatiDI aedtregistratry.tnspan>amemeltesnspan4n classsect2>>ncshref="vfs.html#ass518324">Howttrg Modulesahandla percctnnehery.cdatatnspan>amemelill Opuduccesnspan4n classsect1>>ncshref="vfs.html#ass518529">Upgradcnl loalre New VFS Iut& facetnspan>amemeltdmsuSuccesnspan4n classsect2>>ncshref="vfs.html#ass518535>nUpgradcnl fl en2.2.* aedt3.0aplhatmodulesesa>tnspan>amemelill Opuduccesnspan4n classsect1>>ncshref="vfs.html#ass518965>nSome Notesesa>tnspan>amemeltdmsuSuccesnspan4n classsect2>>ncshref="vfs.html#ass518971>>I 220menx TRANSPARENT funhery.stnspan>amemeltesnspan4n classsect2>>ncshref="vfs.html#ass518991>>I 220menx OPAQUE funhery.stnspan>amemelill Opuducill Opuchmsuch4n classsect1> lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass517991>>Trg Samba (Posix) VFS lay&v lang="en"msuch4n classtitlepage"msuchmsuchmsh34n classtitle>n>csen m="ass517997>>Trg generul iut& face EachtVFS up&vatry. hasaa vfs_op_type,"a funhery. poineer nd"aaahandla poineer i ctn/ structtvfs_ops ad"atree macros loamakecittgascercto call lre up&vatry.s. (Takeca look atlninclude/vfs.htn t> ad"aninclude/vfs_macros.htn t>.) n typedef enum _vfs_op_type { SMB_VFS_OP_NOOP = -1, ... /* Filetup&vatry.s */ SMB_VFS_OP_OPEN, SMB_VFS_OP_CLOSE, SMB_VFS_OP_READ, SMB_VFS_OP_WRITE, SMB_VFS_OP_LSEEK, SMB_VFS_OP_SENDFILE, ... SMB_VFS_OP_LAST } vfs_op_type; This struct ntn"ains lrg"funhery. ad"ahandla poineers foraall up&vatry.s.n structtvfs_ops { structtvfs_fn_poineers { ... /* Filetup&vatry.s */ ine (*op&n)(structtvfs_handla_structt*handla, struct ntnnehery._structt*ntnn, ctnst ch> *fen m, ine flags, mode_t mode); ine (*close)(structtvfs_handla_structt*handla, struct files_structt*fsp, ine fd); ssize_e (*read)(structtvfs_handla_structt*handla, struct files_structt*fsp, ine fd, voidF*data, size_e n); ssize_e (*write)(structtvfs_handla_structt*handla, struct files_structt*fsp, ine fd, ctnst voidF*data, size_e n); SMB_OFF_T (*lseek)(structtvfs_handla_structt*handla, struct files_structt*fsp, ine fd, SMB_OFF_T offset, ine whgnce); ssize_e (*sendeile)(structtvfs_handla_structt*handla, iex tofd, files_structt*fsp, ine fl efd, ctnst DATA_BLOBt*heaper, SMB_OFF_T offset, size_e coun ); ... }tups; structtvfs_handlas_poineers { ... /* Filetup&vatry.s */ structtvfs_handla_structt*op&n; structtvfs_handla_structt*close; structtvfs_handla_structt*read; structtvfs_handla_structt*write; structtvfs_handla_structt*lseek; structtvfs_handla_structt*sendeile; ... }thandlas; }; Tris macros SHOULDabe used to call any vfs up&vatry.. DO NOT ACCESS ntnn->vfs.ups.* direhely !!! n ... /* Filetup&vatry.s */ #defiue4SMB_VFS_OPEN(ntnn, fen m, flags, mode) \ ((ntnn)->vfs.ups.op&n((ntnn)->vfs.handlas.op&n,\ (ntnn), (fen m), (flags), (mode))) #defiue4SMB_VFS_CLOSE(fsp, fd) \ ((fsp)->ntnn->vfs.ups.close(\ (fsp)->ntnn->vfs.handlas.close, (fsp), (fd))) #defiue4SMB_VFS_READ(fsp, fd, data, n) \ ((fsp)->ntnn->vfs.ups.read(\ (fsp)->ntnn->vfs.handlas.read,\ (fsp), (fd), (data), (n))) #defiue4SMB_VFS_WRITE(fsp, fd, data, n) \ ((fsp)->ntnn->vfs.ups.write(\ (fsp)->ntnn->vfs.handlas.write,\ (fsp), (fd), (data), (n))) #defiue4SMB_VFS_LSEEK(fsp, fd, offset, whgnce) \ ((fsp)->ntnn->vfs.ups.lseek(\ (fsp)->ntnn->vfs.handlas.lseek,\ (fsp), (fd), (offset), (whgnce))) #defiue4SMB_VFS_SENDFILE(tofd, fsp, fl efd, heaper, offset, coun ) \ ((fsp)->ntnn->vfs.ups.sendeile(\ (fsp)->ntnn->vfs.handlas.sendeile,\ (tofd), (fsp), (fl efd), (heaper), (offset), (coun ))) ... lang="en"msuch4n classtitlepage"msuchmsuchmsh34n classtitle>n>csen m="ass518094>nPos Lble VFS up&vatry. lay&vs Trese salues are used by lrg"VFS subsystemFwhgn buildcnl th0tconn->vfs ad"acy.n->vfs_opaqu0tstructs foraaactnnehery.cw th multiple VFS modules. Int& nally, Samba differentiates only opaqu0tnd"atransparenttlay&vs at lris process. Olrgr typestare used for providcnl bett&v diagnosinl facillties. Mostamodules will provideatransparenttlay&vs. Opaqu0tlay&vcis fortmodules whichti 220menx actualtfile system callsc(like DB-basedcVFS). Fortgxa 220, default POSIX VFS whichtis built in in o Samba is an opaqu0tVFS module. Olrgr lay&vctypest(logger, splltter, scanner) wgrm deslgned to provideadifferentt degree usttransparency ad"afor diagnosinl VFS module behaviour. Eachtmodule can i 220menx seseral lay&vs at lrs sn mcti m providedltraa u.ly o.e lay&vcis used perceachtup&vatry.. n typedef enum _vfs_op_lay&vc{ SMB_VFS_LAYER_NOOP = -1, /* - Fortusingain VFS module toaindicate dedtoftarray */ /* ustop&vatry.s descriptry.c*/ SMB_VFS_LAYER_OPAQUE = 0, /* - Final lesel, does not call anythcnl beyod"aitself */ SMB_VFS_LAYER_TRANSPARENT, /* - Normaltop&vatry., callscun rlyinl lay&vcaft&v */ /* pos Lblytchangingapcssed datal*/ SMB_VFS_LAYER_LOGGER, /* - Logs data, callscun rlyinl lay&v,cloggrnl may not */ /* use Samba VFS */ SMB_VFS_LAYER_SPLITTER, /* - Splltstop&vatry., callscun rlyinl lay&vc_ad"_ ow. facillty, */ /* trencctmbcnes result */ SMB_VFS_LAYER_SCANNER /* - Checks datalad"apos Lblytiuierates addiery.al */ /* file actrvltyclikecloggrnl toafiles _inside_ samba VFS */ } vfs_op_lay&v; lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass518168">Trg Int& acery. betwee ctrg Samba VFS subsystemFad"ath0tmodulesesh2msptlemsptlemsuchmsptlemsptlemsuch4n classsect2> lang="en"msuch4n classtitlepage"msuchmsuchmsh34n classtitle>n>csen m="ass518174">I ieralizatiDI aedtregistratry. AsceachtSamba module a VFS module shoul"ahaseca nNTSTATUS vfs_gxa 220_iuie(void);"funhery. ifcit'sFstaticlyclcnked to samba or nNTSTATUS iuie_module(void);"funhery. ifcit'sFaash> Td module. Tris shoul"abe lrg"onlycny.tstatic"funhery. insideath0tmodule. Global varinbles shoul"aalso betstatic! Th0tmodule shoul"aregisterai safunhery.scsia lrg n NTSTATUS smb_register_vfs(ine sersion, ctnst ch> *en m, vfs_op_tuple *vfs_op_tuples); afunhery.. sersiontnspan>amemeltdmsp>shoul"abe filledFw th SMB_VFS_INTERFACE_VERSIONen mtnspan>amemeltdmsp>tris is lre en mcw tch can4be lcsted in tre4 vfs ubjehestnb> pdrametercto use this module.vfs_op_tuplestnspan>amemeltdmsp> tris is an array ustsfs_op_tuple's. (vfs_op_tuples is descripted in details below.) Fortgachtup&vatry.ath0tmodule waexs to provideait hasaaldexrycin tre4 vfs_op_tuple array. n typedef structt_vfs_op_tuple { void*tup; vfs_op_type type; vfs_op_lay&vclay&v; }tsfs_op_tuple; optnspan>amemeltdmsp>tre funhery. poineer to4trg specified funhery..typetnspan>amemeltdmsp>tre vfs_op_type ustlrg"funhery. to specified w tch up&vatry.ath0tfunhery. provides.lay&vamemeltdmsp>tre vfs_op_lay&vciI whitchttre funhery. up&vates.A si 220tgxa 220:n static"vfs_op_tuple gxa 220_op_tuples[] = { {SMB_VFS_OP(gxa 220_ctnnehe), SMB_VFS_OP_CONNECT, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(gxa 220_disctnnehe), SMB_VFS_OP_DISCONNECT, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(gxa 220_reen m), SMB_VFS_OP_RENAME, SMB_VFS_LAYER_OPAQUE}, /* Tris indicates lre dedtoftlre array */ {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP} }; NTSTATUS iuie_module(void) { return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "exa 220", gxa 220_op_tuples); } lang="en"msuch4n classtitlepage"msuchmsuchmsh34n classtitle>n>csen m="ass518324">Howttrg Modulesahandla percctnnehery.cdataEachtVFS funhery. hasaas first pdrameterca poineer to4trg modules vfs_handla_struct. n typedef structtvfs_handla_structt{ structtvfs_handla_structt *eext, *prev; ctnst ch> *pdram; structtvfs_ops vfs_eext; structtntnnehery._structt*ntnn; voidF*data; voidF(*free_data)(voidF**data); }tsfs_handla_struct; pdramtnspan>amemeltdmsp>tris is lre module pdrametercspecified i ctn/ vfs ubjehestnb> pdrameter.e.g.afor 'vfs ubjehes = gxa 220:test' pdram woul"abg "test".vfs_nextesspan>amemeltdmsp>Tris vfs_ops struct ntn"ains lrg"informaary. for callrngttrg nextamodule up&vatry.s. Use th0tSMB_VFS_NEXT_* macros loacall a nextamodule up&vatry.scad" don't nccesschandla->vfs_next.ups.* direhely!ntnnesspan>amemeltdmsp>Tris isaacpoineer back to4trg ntnnehery._structtto4witchttre handla belongs.dataamemeltdmsp>Tris isaacpoineer fortroldcnl module pr vute data. Youccan alloc datalw th ctnnehery.clifmcti m y.ath0thandla->cy.n->mem_ctx TALLOC_CTX. Buxtyouccan also mndage lr0tmemoryFallocaary. yourself.free_dataamemeltdmsp>Tris isaacfunhery. poineer to4acfunhery. nat4free's lre module pr vute data. Iftyouctalloc yourFpr vute data y.ath0tTALLOC_CTXthandla->cy.n->mem_ctx, youccan set lris funhery. poineer to4NULL.Some useful MACROS fortrandla pr vute data. n #defiue4SMB_VFS_HANDLE_GET_DATA(handla, datap, type,"ret) { \ ifc(!(handla)||((datap=(type *)(handla)->data)==NULL)) { \ DEBUG(0,("%s() fail dFto gettvfs_handla->data!\n",FUNCTION_MACRO)); \ ret; \ } \ } #defiue4SMB_VFS_HANDLE_SET_DATA(handla, datap, free_fn, type,"ret) { \ ifc(!(handla)) { \ DEBUG(0,("%s() fail dFto set handla->data!\n",FUNCTION_MACRO)); \ ret; \ } else { \ ifc((handla)->free_data) { \ (handla)->free_data(&a 2;(handla)->data); \ } \ (handla)->data = (voidF*)datap; \ (handla)->free_data = free_fn; \ } \ } #defiue4SMB_VFS_HANDLE_FREE_DATA(handla) { \ ifc((handla) &a 2;&a 2; (handla)->free_data) { \ (handla)->free_data(&a 2;(handla)->data); \ } \ } HowtSMB_VFS_LAYER_TRANSPARENTafunhery.sccan call lre SMB_VFS_LAYER_OPAQUE funhery.s.Th0tgascesttway lo do4thiscis loause th0tSMB_VFS_OPAQUE_* macros. n ... /* Filetup&vatry.s */ #defiue4SMB_VFS_OPAQUE_OPEN(ntnn, fen m, flags, mode) \ ((ntnn)->vfs_opaqu0.ups.op&n(\ (ntnn)->vfs_opaqu0.handlas.op&n,\ (ntnn), (fen m), (flags), (mode))) #defiue4SMB_VFS_OPAQUE_CLOSE(fsp, fd) \ ((fsp)->ntnn->vfs_opaqu0.ups.close(\ (fsp)->ntnn->vfs_opaqu0.handlas.close,\ (fsp), (fd))) #defiue4SMB_VFS_OPAQUE_READ(fsp, fd, data, n) \ ((fsp)->ntnn->vfs_opaqu0.ups.read(\ (fsp)->ntnn->vfs_opaqu0.handlas.read,\ (fsp), (fd), (data), (n))) #defiue4SMB_VFS_OPAQUE_WRITE(fsp, fd, data, n) \ ((fsp)->ntnn->vfs_opaqu0.ups.write(\ (fsp)->ntnn->vfs_opaqu0.handlas.write,\ (fsp), (fd), (data), (n))) #defiue4SMB_VFS_OPAQUE_LSEEK(fsp, fd, offset, whgnce) \ ((fsp)->ntnn->vfs_opaqu0.ups.lseek(\ (fsp)->ntnn->vfs_opaqu0.handlas.lseek,\ (fsp), (fd), (offset), (whgnce))) #defiue4SMB_VFS_OPAQUE_SENDFILE(tofd, fsp, fl efd, heaper, offset, coun ) \ ((fsp)->ntnn->vfs_opaqu0.ups.sendeile(\ (fsp)->ntnn->vfs_opaqu0.handlas.sendeile,\ (tofd), (fsp), (fl efd), (heaper), (offset), (coun ))) ... HowtSMB_VFS_LAYER_TRANSPARENTafunhery.sccan call lre nextamodules funhery.s.Th0tgascesttway lo do4thiscis loause th0tSMB_VFS_NEXT_* macros. n ... /* Filetup&vatry.s */ #defiue4SMB_VFS_NEXT_OPEN(handla, ntnn, fen m, flags, mode) \ ((handla)->vfs_next.ups.op&n(\ (handla)->vfs_next.handlas.op&n,\ (ntnn), (fen m), (flags), (mode))) #defiue4SMB_VFS_NEXT_CLOSE(handla, fsp, fd) \ ((handla)->vfs_next.ups.close(\ (handla)->vfs_next.handlas.close,\ (fsp), (fd))) #defiue4SMB_VFS_NEXT_READ(handla, fsp, fd, data, n) \ ((handla)->vfs_next.ups.read(\ (handla)->vfs_next.handlas.read,\ (fsp), (fd), (data), (n))) #defiue4SMB_VFS_NEXT_WRITE(handla, fsp, fd, data, n) \ ((handla)->vfs_next.ups.write(\ (handla)->vfs_next.handlas.write,\ (fsp), (fd), (data), (n))) #defiue4SMB_VFS_NEXT_LSEEK(handla, fsp, fd, offset, whgnce) \ ((handla)->vfs_next.ups.lseek(\ (handla)->vfs_next.handlas.lseek,\ (fsp), (fd), (offset), (whgnce))) #defiue4SMB_VFS_NEXT_SENDFILE(handla, tofd, fsp, fl efd, heaper, offset, coun ) \ ((handla)->vfs_next.ups.sendeile(\ (handla)->vfs_next.handlas.sendeile,\ (tofd), (fsp), (fl efd), (heaper), (offset), (coun ))) ... lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass518529">Upgradcnl loalre New VFS Iut& face lang="en"msuch4n classtitlepage"msuchmsuchmsh34n classtitle>n>csen m="ass518535>nesa>Upgradcnl fl en2.2.* aedt3.0aplhatmodulesesh3msptlemsptlemsuchmsptlemsptlemsuch4n classorderedlist"msolFtypess1">elimsp> Add "vfs_handla_structt*handla, "aas first pdrametercto4all vfs up&vatry. funhery.s. e.g.agxa 220_ctnnehe(ntnnehery._structt*ntnn, ctnst ch> *scnsice, ctnst ch> *user); -> agxa 220_ctnnehe(vfs_handla_structt*handla, ntnnehery._structt*ntnn, ctnst ch> *scnsice, ctnst ch> *user); Replace "default_vfs_ops."lw th "smb_vfs_next_". e.g.adefault_vfs_ops.ctnnehe(ntnn, scnsice, user); -> asmb_vfs_next_ctnnehe(ntnn, scnsice, user); Uppercase all "smb_vfs_next_*" funhery.s. e.g.asmb_vfs_next_ctnnehe(ntnn, scnsice, user); -> aSMB_VFS_NEXT_CONNECT(ntnn, scnsice, user); Add "handla, "aas first pdrametercto4all SMB_VFS_NEXT_*() calls. e.g.aSMB_VFS_NEXT_CONNECT(ntnn, scnsice, user); -> aSMB_VFS_NEXT_CONNECT(handla, ntnn, scnsice, user); (Onlycforn2.2.* modules) Convert lre old structtvfs_ops gxa 220_ops loa a"vfs_op_tuple gxa 220_op_tuples[] array. e.g. n structtvfs_ops gxa 220_ops =t{ /* Disk op&vatry.s */ gxa 220_ctnnehe, /* cy.nehea*/ gxa 220_disctnnehe, /* disctnnehea*/ NULL, /* disk free * /* Direheorycop&vatry.s */ NULL, /* op&ndir */ NULL, /* readdir */ NULL, /* mkdir */ NULL, /* rmdir */ NULL, /* closedir */ /* Filetup&vatry.s */ NULL, /* op&n */ NULL, /* close */ NULL, /* read */ NULL, /* write */ NULL, /* lseek */ NULL, /* sendeile */ NULL, /* reen mc*/ NULL, /* fsynca*/ gxa 220_stat, /* stat a*/ gxa 220_fstat, /* fstata*/ gxa 220_lstat, /* lstata*/ NULL, /* unlinkc*/ NULL, /* chmodc*/ NULL, /* fchmodc*/ NULL, /* chow. */ NULL, /* fchow. */ NULL, /* chdir */ NULL, /* getwdc*/ NULL, /* utime */ NULL, /* ftruncate */ NULL, /* lock */ NULL, /* symlinkc*/ NULL, /* readlinkc*/ NULL, /* linkc*/ NULL, /* mknodc*/ NULL, /* realpath */ NULL, /* fget_nt_acl */ NULL, /* get_nt_acl */ NULL, /* fset_nt_acl */ NULL, /* set_nt_acl */ NULL, /* chmod_acl */ NULL, /* fchmod_acl */ NULL, /* sys_acl_get_dexryc*/ NULL, /* sys_acl_get_tag_type */ NULL, /* sys_acl_get_p&vmset */ NULL, /* sys_acl_get_qualifier */ NULL, /* sys_acl_get_eile */ NULL, /* sys_acl_get_ed */ NULL, /* sys_acl_clear_p&vms */ NULL, /* sys_acl_add_p&vm */ NULL, /* sys_acl_to_text */ NULL, /* sys_acl_iuie */ NULL, /* sys_acl_creatg_dexryc*/ NULL, /* sys_acl_set_tag_type */ NULL, /* sys_acl_set_qualifier */ NULL, /* sys_acl_set_p&vmset */ NULL, /* sys_acl_salid */ NULL, /* sys_acl_set_eile */ NULL, /* sys_acl_set_ed */ NULL, /* sys_acl_delete_def_eile */ NULL, /* sys_acl_get_p&vm */ NULL, /* sys_acl_free_text */ NULL, /* sys_acl_free_acl */ NULL /* sys_acl_free_qualifier */ }; -> n static"vfs_op_tuple gxa 220_op_tuples[] = { {SMB_VFS_OP(gxa 220_ctnnehe), SMB_VFS_OP_CONNECT, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(gxa 220_disctnnehe), SMB_VFS_OP_DISCONNECT, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(gxa 220_fstat), SMB_VFS_OP_FSTAT, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(gxa 220_stat), SMB_VFS_OP_STAT, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(gxa 220_lstat), SMB_VFS_OP_LSTAT, SMB_VFS_LAYER_TRANSPARENT}, {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP} }; Movetlrg"gxa 220_op_tuples[] array loalre dedtoftlre eile. Add lrg"inie_module()"funhery. atalre dedtoftlre eile. e.g. n NTSTATUS iuie_module(void) { return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,"exa 220",gxa 220_op_tuples); } Check ifcyourFvfs_iuie()"funhery. does more trencjustlprepareFtne vfs_ops structs or remember lr0tstructasmb_vfs_handla_struct. If NOT youccan removetlrg"vfs_iuie()"funhery..If YES decideaiftyoucwaex to movetlrg"codeFloalre dxa 220_ctnnehe() up&vatry. or toalre inie_module(). Ad"ath0n removetvfs_iuie(). ag.g.aa debug n clatregistratry. shoul"ago in o inie_module()"ad"ath0tallocaary. yf pr vute data shoul"ago to exa 220_ctnnehe().

(Onlycforn3.0alpha* modules) Check ifcyourFvfs_done()"funhery. ntn"ains ne ded code. If NOT youccan removetlrg"vfs_done()"funhery..If YES decideaiftyouccan movetlrg"codeFloalre dxa 220_disctnnehe() up&vatry.. Olrgrwise registeraa SMB_EXIT_EVENTas th smb_register_0xit_ev/ne(); (Described i ctn/ modules s&ctry.esa>) Ad"ath0n removetvfs_done().ag.g.alre ereeinl ustpr vute data shoul"ago to exa 220_disctnnehe().

Check ifcyouahasecany global varinbles left. Decideaiftitnwoul"n't be bett&v to hasecthiscdata y.aaactnnehery.cbasis. If NOT leavec n/m asclrgy arm. (g.g.alris coul"abe lrg"varinble forath0tpr vute debug n cla.)If YES pcck all lriscdata in o atstruct. Youccan use handla->data lo poiex to4suchtatstructay.aaapercctnnehery.cbasis.

ag.g.aifcyouahasecsuchtatstruct: n structaexa 220_pr vutes { ch> *soma_string; iex db_ctnnehery.; }; first way us doingtit: n static"iex gxa 220_ctnnehe(vfs_handla_structt*handla, ctnnehery._structt*ntnn, ctnst ch> *scnsice, ctnst ch> * user) { structtexa 220_pr vutes *data = NULL; /* alloc ourFpr vute data */ data = (structtexa 220_pr vutes *)talloc_zero(cy.n->mem_ctx, sizeof(structtexa 220_pr vutes)); ifc(!data) { DEBUG(0,("talloc_zero() fail d\n")); return -1; } /* iuie out pr vute data */ data->soma_string = talloc_strdup(cy.n->mem_ctx,"test"); ifc(!data->soma_string) { DEBUG(0,("talloc_strdup() fail d\n")); return -1; } data->db_ctnnehery. = op&n_db_ctnn(); /* ad"anowtstore tre pr vute data poineer i chandla->data * we don't ne dFto specify a free_funhery. hgrm because * we use th0tctnnehery. TALLOC ct "dxt. * (return -1aifcsomethcnl fail d.) */ VFS_HANDLE_SET_DATA(handla, data, NULL, structtexa 220_pr vutes,"return -1); return SMB_VFS_NEXT_CONNECT(handla,ntnn,scnsice,user); } static"iex gxa 220_close(vfs_handla_structt*handla, files_structt*fsp, ine fd) { structtexa 220_pr vutes *data = NULL; /* get tre poineer to4ourFpr vute data * return -1aifcsomethcnl fail d */ SMB_VFS_HANDLE_GET_DATA(handla, data, structtexa 220_pr vutes,"return -1); /* do somethcnl hgrm...*/ DEBUG(0,("soma_string: %s\n",data->soma_string)); return SMB_VFS_NEXT_CLOSE(handla, fsp, fd); } sentnd way us doingtit: n static"voidFfree_exa 220_pr vutes(voidF**datap) { structtexa 220_pr vutes *data = (structtexa 220_pr vutes *)*datap; SAFE_FREE(data->soma_string); SAFE_FREE(data); *datap = NULL; return; } static"iex gxa 220_ctnnehe(vfs_handla_structt*handla, ctnnehery._structt*ntnn, ctnst ch> *scnsice, ctnst ch> * user) { structtexa 220_pr vutes *data = NULL; /* alloc ourFpr vute data */ data = (structtexa 220_pr vutes *)malloc(sizeof(structtexa 220_pr vutes)); ifc(!data) { DEBUG(0,("malloc() fail d\n")); return -1; } /* iuie out pr vute data */ data->soma_string = strdup("test"); ifc(!data->soma_string) { DEBUG(0,("strdup() fail d\n")); return -1; } data->db_ctnnehery. = op&n_db_ctnn(); /* ad"anowtstore tre pr vute data poineer i chandla->data * we ne dFto specify a free_funhery. because we used malloc() ad"astrdup(). * (return -1aifcsomethcnl fail d.) */ SMB_VFS_HANDLE_SET_DATA(handla, data,Ffree_exa 220_pr vutes, structtexa 220_pr vutes,"return -1); return SMB_VFS_NEXT_CONNECT(handla,ntnn,scnsice,user); } static"iex gxa 220_close(vfs_handla_structt*handla, files_structt*fsp, ine fd) { structtexa 220_pr vutes *data = NULL; /* get tre poineer to4ourFpr vute data * return -1aifcsomethcnl fail d */ SMB_VFS_HANDLE_GET_DATA(handla, data, structtexa 220_pr vutes,"return -1); /* do somethcnl hgrm...*/ DEBUG(0,("soma_string: %s\n",data->soma_string)); return SMB_VFS_NEXT_CLOSE(handla, fsp, fd); } Toamakecittgasy loabuild 3rdapartyamodules itnwoul"abe usefull to provide configurm.in, (configurm), install.shFad"aMakeeile.in w th lrs module. (Takeca look atllre dxa 220 i cndxa 220s/VFStn t>.) Th0tconfigurm script ncceptsc--w th-samba-sourcetn t> to specify th0tpath to4trg samba source tree. I calso ncceptc--eenble-deselopertn t> whichtlets lrs compiler giv/ youamore warnrngs. Th0tidea isctraxtyouccan ext&ndclris nconfigurm.intn t> ad"anMakeeile.intn t> scripts forayourFmodule. Compilcnl &a 2; Testing... ./configurm --eenble-deselopertn t>tn t>tnb> ...maketn t>tnb>Try toafix all compiler warnrngsmaketn t>tnb>Testing, Testing, Testing ...

lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle> sfylessclear: both>n>csen m="ass518965>nesa>Some Notesesh2msptlemsptlemsuchmsptlemsptlemsuch4n classsect2> lang="en"msuch4n classtitlepage"msuchmsuchmsh34n classtitle>n>csen m="ass518971>>I 220menx TRANSPARENT funhery.s AvoidFwritcnl funhery.sclikeclris: n static"iex gxa 220_close(vfs_handla_structt*handla, files_structt*fsp, ine fd) { return SMB_VFS_NEXT_CLOSE(handla, fsp, fd); } Overlond unlyttre funhery.styoucreallycne dFto! lang="en"msuch4n classtitlepage"msuchmsuchmsh34n classtitle>n>csen m="ass518991>>I 220menx OPAQUE funhery.s Iftyoucwaex to justli 220menx a bett&v sersiontofta default samba opaqu0tfunhery. (g.g.alikeca disk_free()"funhery. foraaaspecialtfilesystem)c it'sFok to justloverlond tnaxtspecificafunhery.. Iftyoucwaex to i 220menx a databasetfilesystem or somethcnl differenttfl ena posixtfilesystem. Make sure naxtyoucoverlond ev/ry vfs up&vatry.!!! Funhery.styour FS does not support shoul"abe overlonded by somethcnl likeclris: e.g.afor a readunlytfilesystem. n static"iex gxa 220_reen m(vfs_handla_structt*handla, ntnnehery._structt*ntnn, ch> *olden m, ch> *eewen m) { DEBUG(10,("funhery. reen m()teot allowedcon vfs 'gxa 220'\n")); errno = ENOSYS; return -1; } Prevesa> Upesa>Nextesa>Chapx r 11. RPC Pluggnble Modules Home Chapx r 13. Th0tregistry subsystemes dr